package com.java.controller;

import com.java.domain.Admin;
import com.java.service.AdminService;
import com.java.service.impl.AdminServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(value = "/admin/*")
public class AdminServlet extends BaseServlet {
    private AdminService adminService = new AdminServiceImpl();
    public void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //接收前台数据
        String admin_number = request.getParameter("username");
        String admin_password = request.getParameter("password");
        System.out.println(admin_number);
        System.out.println(admin_password);

        Admin admin1 = new Admin();
        admin1.setAdmin_number(admin_number);
        admin1.setAdmin_password(admin_password);

        //将对象传给业务层
        Admin admin =adminService.Loginlogin(admin1);
        if (admin==null){
           /* request.setAttribute("msg","您输入的账号不正确");
            response.sendRedirect("../login2.html");*/
            response.getWriter().println(0);
        }else{
           /* request.getSession().setAttribute("admin",admin);
            response.sendRedirect("../index_backstage.html");*/

            response.getWriter().println(1);

        }

    }
}
